#!/bin/bash

echo AUTO MONO CENTOS
echo UPDATEING SYSTEM

echo METHOD=$METHOD
yum -y update
yum -y install gcc gcc-c++ 
yum -y install autoconf automake
yum -y install bison pkgconfig glib2-devel gettext make
yum -y install httpd-devel
yum -y install xorg-\*-devel
yum -y install freetype-devel
yum -y install fontconfig-devel
yum -y install gtk2-devel
yum -y install mozilla-nspr-devel
yum -y install mozilla-nss-devel
yum -y install xulrunner-devel
yum -y update
read
echo UPDATEING SYSTEM COMPLETE PRESS ENTER TO CONTINUE

#-----------------------------------------------------------
# script debugging
# do not DEBUG just RUN
PRESS=
# DEBUG stop and wait
#PRESS=read
echo "Press any Key" ; $PRESS
#-----------------------------------------------------------

echo #####################################################
#VARIABLES - CHANGE TO NEWEST VERSION
# example:  MONO_BASIC			-> variable
#			mono-basic-2.6.2	-> package version
#			go to web page (above every variable) and find 
#			the latest version of package. 
#			Change every package version with new one.


echo "#####################################################################"

echo "################ LIBGDIPLUS ################"
#http://ftp.novell.com/pub/mono/sources/libgdiplus/
LIBGDIPLUS=libgdiplus-2.8

echo $LIBGDIPLUS
echo Downloading $LIBGDIPLUS ...
wget http://ftp.novell.com/pub/mono/sources/libgdiplus/$LIBGDIPLUS.tar.bz2
tar jxvf $LIBGDIPLUS.tar.bz2
cd $LIBGDIPLUS

echo Configuring libgdiplus ...
./configure; 

echo Installing libgdiplus ...
make all; make install

#echo If you ever happen to want to link against installed libraries
#echo in a given directory, LIBDIR, you must either use libtool, and
#echo specify the full pathname of the library, or use the `-LLIBDIR'
#echo flag during linking and do at least one of the following:
#echo    - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
#echo      during execution
#echo    - add LIBDIR to the `LD_RUN_PATH' environment variable
#echo      during linking
#echo    - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
#echo    - have your system administrator add LIBDIR to `/etc/ld.so.conf'

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
LD_RUN_PATH=$LD_RUN_PATH:/usr/local/lib/

echo /usr/local/lib >> /etc/ld.so.conf
/sbin/ldconfig


PATH_CONFIG="
PATH=/usr/local/bin:$PATH
LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
LD_RUN_PATH=/usr/local/lib/:$LD_RUN_PATH
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
export PATH
export LD_LIBRARY_PATH
export LD_RUN_PATH
export PKG_CONFIG_PATH
"

echo "$PATH_CONFIG" >> ~/.bashrc
cat ~/.bashrc

echo "$PATH_CONFIG" >> ~/.bash_profile
cat ~/.bash_profile

bash

echo "Press any Key" ; $PRESS
cd ..
rm -fr $LIBGDIPLUS
echo "################ END OF LIBGDIPLUS ################"

echo "################### MONO ###################"
#http://ftp.novell.com/pub/mono/sources/mono/
MONO=mono-2.8

#--------------------------------------------------------------------
# 2.6.7, 2.6.4 
# compile error
# mono decl.cs: error CS0246: The type or namespace name `var' could 
# not be found
# 
# Note: this means older mono not suporting var is in PATH
#--------------------------------------------------------------------
echo $MONO 
echo Downloading $MONO ...
wget http://ftp.novell.com/pub/mono/sources/mono/$MONO.tar.bz2
echo Download of $MONO finished!
tar jxvf $MONO.tar.bz2
cd $MONO

echo Configuring mono ...
#./configure -prefix=/opt/mono; 
./configure

echo Installing mono ...
make
make install

which mono

echo "Press any Key" ; $PRESS

echo Exporting path ...
echo export PATH=/usr/local/bin/:$PATH >> ~/.bash_profile
echo source ~/.bash_profile
echo export PATH=/usr/local/bin/:$PATH >> ~/.bashrc
echo source ~/.bashrc

echo "Press any Key" ; $PRESS
echo
echo Testing $MONO
mono --version
echo
echo Testing GMCS (C#)
gmcs --version

echo "Press any Key" ; $PRESS
cd ..
rm -rf $MONO
echo "################### END OF MONO ###################"

echo "################ MONO_BASIC ################"
#http://ftp.novell.com/pub/mono/sources/mono-basic/
MONO_BASIC=mono-basic-2.8

echo $MONO_BASIC 
echo Downloading $MONO_BASIC ...
wget http://ftp.novell.com/pub/mono/sources/mono-basic/$MONO_BASIC.tar.bz2
tar jxvf $MONO_BASIC.tar.bz2
cd $MONO_BASIC

echo Configuring mono-basic ...
./configure; 

echo Installing mono-basic ...
make all; make install

echo "Press any Key" ; $PRESS
cd ..
rm -fr $MONO_BASIC
echo "################ END OF MONO_BASIC ################"


echo "################ GLUEZILLA ################"
#http://ftp.novell.com/pub/mono/sources/gluezilla/
GLUEZILLA=gluezilla-2.6

echo $GLUEZILLA
echo Downloading $GLUEZILLA ...
wget http://ftp.novell.com/pub/mono/sources/gluezilla/$GLUEZILLA.tar.bz2
tar jxvf $GLUEZILLA.tar.bz2
cd $GLUEZILLA

echo Configuring gluezilla ...
./configure; 

echo Installing gluezilla ...
make all; make install

echo "Press any Key" ; $PRESS
cd ..
rm -fr $GLUEZILLA
echo "################ END OF GLUEZILLA ################"

echo "################ XSP ####################"			
#http://ftp.novell.com/pub/mono/sources/xsp
XSP=xsp-2.8

echo $XSP
echo Downloading $XSP ...
wget http://ftp.novell.com/pub/mono/sources/xsp/$XSP.tar.bz2
tar jxvf $XSP.tar.bz2
cd $XSP

echo Configuring xsp ...
#./configure --with-runtime=/usr/local/bin/mono; 
./configure 

# ERROR:
# Package dotnet was not found in the pkg-config search path.
# Perhaps you should add the directory containing `dotnet.pc'
# to the PKG_CONFIG_PATH environment variable
# No package 'dotnet' found
# Use locate dotnet.pc and change /opt/mono/lib/pkgconfig with your path

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/

echo Installing xsp ...
make all; make install

echo "Press any Key" ; $PRESS
cd ..
rm -fr $XSP
echo "################ END OF XSP ################"

echo "################ MOD_MONO ################"
#http://ftp.novell.com/pub/mono/sources/mod_mono/
MOD_MONO=mod_mono-2.8

echo $MOD_MONO
echo Downloading $MOD_MONO ...	
wget http://ftp.novell.com/pub/mono/sources/mod_mono/$MOD_MONO.tar.bz2
tar jxvf $MOD_MONO.tar.bz2
cd $MOD_MONO

echo Configuring mod_mono ...
./configure 

echo Installing mod_mono ...
make all; make install

echo "Press any Key" ; $PRESS
cd ..
rm -fr $MOD_MONO
echo "################ END OF MOD_MONO ################"

#INFO:  http://blog.rubypdf.com/2009/10/23/how-to-install-xsp-and-integrate-xsp-with-apache-2-under-centos-5/
#		http://poormanstech.blogspot.com/2007/05/installing-mono.html
	




